import regeneratorRuntime from '../../lib/runtime/runtime'
import { request } from '../../request/index'
import { z_login } from '../../utils/async_wx'
// pages/auth/auth.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  async handleGetToken(event) {
    try {
      const { encryptedData, iv, rawData, signature } = event.detail
      const result1 = await z_login()
      const { code } = result1
      const result2 = await request({
        url: '/users/wxlogin', data: {
          encryptedData, iv, rawData, signature, code
        },methods:"POST"
      })
      //个人开发账号就只能做到这里了,假设获取到了token存储到本地
      wx.setStorageSync('token', '201717');
      wx.showToast({
        title: '无效的token',
        icon: 'none',
        duration: 2000,
        mask: true,
      })
      //跳转回支付页面
      wx.navigateBack({
        delta: 1
      });
      // console.log(result2)
    } catch (error) {
      console.log(error)
    }
  },

 
})